/*    
 * THis file is part of the xoperator SPARQL/XMPP agent.
 * For further information see: http://xoperator.sf.net
 * Copyright (C) 2007  Jörg Unbehauen  

 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */
package net.sf.xoperator.xmpp;

import net.sf.xoperator.configuration.PersistentKSConfiguration;

/**
 * bundles all the information necessary to connect to a server and login
 * 
 * @author joerg
 * 
 */
public class AccountInfo extends PersistentKSConfiguration {
	

	public static final String MAIN = "main";

	public static final String PROXY = "proxy";

	private String username;

	private String password;

	private String server;

	private String resource;

	private Integer port;

	private boolean mainAccount;

	private boolean obsolete;
	
	private boolean standalone = false;
	
	private boolean p2penabled = false;
	
	public void setP2penabled(boolean p2penabled) {
		this.p2penabled = p2penabled;
	}
	
	public boolean isP2penabled() {
		return p2penabled;
	}
	
	public void setStandalone(boolean standalone) {
		this.standalone = standalone;
	}
	
	public boolean isStandalone() {
		return standalone;
	}

	@Override
	public boolean isObsolete() {
		return this.obsolete;
	}

	@Override
	public void setObsolete(boolean obsolete) {
		this.obsolete = obsolete;
	}

	public boolean isMainAccount() {
		return this.mainAccount;
	}
	

	@Override
	public String getName() {
		return this.mainAccount ? MAIN : PROXY;
	}

	public void setMainAccount(boolean mainAccount) {
		this.mainAccount = mainAccount;
	}

	public boolean validate() {
		if (this.username != null && !this.username.isEmpty() && this.username.contains("@")
				&& this.password != null && !this.password.isEmpty()) {
			return true;
		}
		return false;
	}

	public String getResource() {
		return this.resource;
	}

	public void setResource(String resource) {
		this.resource = resource;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getPort() {
		return this.port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}

	public String getServer() {
		return this.server;
	}

	public void setServer(String server) {
		this.server = server;
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

}
